package com.coderly.onlinegallerysharingplatform.toolkit;

import cn.dev33.satoken.stp.StpUtil;
import com.coderly.onlinegallerysharingplatform.enums.UserRoleEnum;


public class UserUtil {

    public static Long getLoginUserId() {
        return StpUtil.getLoginIdAsLong();
    }

    public static Boolean checkIsAdmin(Long loginUserId) {
        return UserRoleEnum.ADMIN.getValue().equals(StpUtil.getRoleList(loginUserId).get(0)) ;
    }

    public static String getLoginUserRole() {
        return StpUtil.getRoleList(StpUtil.getLoginId()).get(0);
    }

    public static Boolean isAdmin() {
        return UserUtil.getLoginUserRole().equals(UserRoleEnum.ADMIN.getValue());
    }
}
